// 
// Entify project
//  
// Author:
//       Lauri Taimila <lauri@taimila.com>
// 
// Copyright (c) 2010 Lauri Taimila
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.Reflection;
using System.Collections.Generic;
using Taimila.Entify;
using Taimila.Entify.Attributes;

/* Generated entity model for Entify system tests. */

namespace Taimila.Entify.SystemTests
{
	[Taimila.Entify.Attributes.Entity(Version=1)]
	public partial class Customer : Entity
	{
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Firstname", IndexName = "CustomerFirstnameIndex")]
		public System.String Firstname
		{
			get;
			set;
		}
	
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Lastname")]
		public System.String Lastname
		{
			get;
			set;
		}
	
		private Address billingAddress;
		private long? billingAddressLazyLoadIdentifier;
	
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "BillingAddress", Relationship = true)]
		public Address BillingAddress
		{
			get
			{
				if(this.billingAddressLazyLoadIdentifier == null)
				{
					return null;
				}
				else if(this.billingAddress == null)
				{
					this.billingAddress = this.LazyLoadEntity<Address>(this.billingAddressLazyLoadIdentifier);
					return this.billingAddress;
				}
				else
				{
					return this.billingAddress;
				}
			}
			set
			{
				if(value == null)
				{
					this.billingAddressLazyLoadIdentifier = null;
					this.billingAddress = null;
				}
				else
				{
	               MethodInfo method = typeof(Entity).GetMethod("GetEntityId", BindingFlags.NonPublic | BindingFlags.Instance);
					this.billingAddressLazyLoadIdentifier = (long?) method.Invoke(value, null);
					this.billingAddress = value;
				}
			}
		}
	
		private Address deliveryAddress;
		private long? deliveryAddressLazyLoadIdentifier;

		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "DeliveryAddress", Relationship = true)]
		public Address DeliveryAddress
		{
			get
			{
				if(this.deliveryAddressLazyLoadIdentifier == null)
				{
					return null;
				}
				else if(this.deliveryAddress == null)
				{
					this.deliveryAddress = this.LazyLoadEntity<Address>(this.deliveryAddressLazyLoadIdentifier);
					return this.deliveryAddress;
				}
				else
				{
					return this.deliveryAddress;
				}
			}
			set
			{
				if(value == null)
				{
					this.deliveryAddressLazyLoadIdentifier = null;
					this.deliveryAddress = null;
				}
				else
				{
	               MethodInfo method = typeof(Entity).GetMethod("GetEntityId", BindingFlags.NonPublic | BindingFlags.Instance);
					this.deliveryAddressLazyLoadIdentifier = (long?) method.Invoke(value, null);
					this.deliveryAddress = value;
				}
			}
		}
	
		private List<ShoppingCart> shoppingCarts;
		#pragma warning disable
		private List<long?> shoppingCartsLazyLoadIdentifiers;
		#pragma warning restore
	
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "ShoppingCarts", Relationship = true)]
		public List<ShoppingCart> ShoppingCarts
		{
			get
			{
				if(this.shoppingCarts == null && this.shoppingCartsLazyLoadIdentifiers == null)
				{
					this.shoppingCarts = new List<ShoppingCart>();
				}
	
				if(this.shoppingCarts == null)
				{
					this.shoppingCarts = this.LazyLoadEntities<ShoppingCart>(this.shoppingCartsLazyLoadIdentifiers);
				}
	
				return this.shoppingCarts;
			}
			set
			{
				if(value == null)
				{
					throw new ArgumentNullException("Entity relation container cannot be set null. Use Clear() to remove all relations.");
				}
				else
				{
					this.shoppingCarts = value;
				}
			}
		}
	
	}
	
	[Taimila.Entify.Attributes.Entity(Version=1)]
	public partial class ShoppingCart : Entity
	{
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Name")]
		public System.String Name
		{
			get;
			set;
		}
	
		private Customer customer;
		private long? customerLazyLoadIdentifier;
	
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Customer", Relationship = true)]
		public Customer Customer
		{
			get
			{
				if(this.customerLazyLoadIdentifier == null)
				{
					return null;
				}
				else if(this.customer == null)
				{
					this.customer = this.LazyLoadEntity<Customer>(this.customerLazyLoadIdentifier);
					return this.customer;
				}
				else
				{
					return this.customer;
				}
			}
			set
			{
				if(value == null)
				{
					this.customerLazyLoadIdentifier = null;
					this.customer = null;
				}
				else
				{
	               MethodInfo method = typeof(Entity).GetMethod("GetEntityId", BindingFlags.NonPublic | BindingFlags.Instance);
					this.customerLazyLoadIdentifier = (long?) method.Invoke(value, null);
					this.customer = value;
				}
			}
		}
	
		private List<Product> products;
		#pragma warning disable
		private List<long?> productsLazyLoadIdentifiers;
		#pragma warning restore

		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Products", Relationship = true)]
		public List<Product> Products
		{
			get
			{
				if(this.products == null && this.productsLazyLoadIdentifiers == null)
				{
					this.products = new List<Product>();
				}
	
				if(this.products == null)
				{
					this.products = this.LazyLoadEntities<Product>(this.productsLazyLoadIdentifiers);
				}
	
				return this.products;
			}
			set
			{
				if(value == null)
				{
					throw new ArgumentNullException("Entity relation container cannot be set null. Use Clear() to remove all relations.");
				}
				else
				{
					this.products = value;
				}
			}
		}
	
	}

	[Taimila.Entify.Attributes.Entity(Version=1)]
	public partial class Product : Entity
	{
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Name")]
		public System.String Name
		{
			get;
			set;
		}
	
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Price")]
		[Taimila.Entify.Attributes.NumericRangeValidator(0, 0)]
		public System.Decimal Price
		{
			get;
			set;
		}
	
	}
	
	[Taimila.Entify.Attributes.Entity(Version=1)]
	public partial class Address : Entity
	{
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "StreetAddress")]
		public System.String StreetAddress
		{
			get;
			set;
		}

		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "ZipCode")]
		public System.UInt32 ZipCode
		{
			get;
			set;
		}

		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "City")]
		public System.String City
		{
			get;
			set;
		}
	
		[Taimila.Entify.Attributes.EntityProperty(PersistentName = "Country")]
		public System.String Country
		{
			get;
			set;
		}
	
	}
}